package cn.com.jslh.boarpro.main.view.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.com.jslh.boarpro.R;
import cn.com.jslh.boarpro.base.BaseFragment;
import cn.com.jslh.boarpro.main.contract.SearchContract;
import cn.com.jslh.boarpro.main.presenter.SearchPresenterImpl;

/**
 * Created by Administrator on 2017/11/10.
 */

public class SearchFragment extends BaseFragment implements SearchContract.View {

    @BindView(R.id.recycleview)
    RecyclerView recycleview;
    private SearchContract.Presenter presenter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new SearchPresenterImpl(getContext(), this);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.search_layout, container, false);
        unbinder = ButterKnife.bind(this, view);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
//        layoutManager.setAutoMeasureEnabled(true);
        recycleview.setLayoutManager(layoutManager);
        recycleview.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
        presenter.bindRV(recycleview);
        presenter.start();
        return view;
    }

    @Override
    public void setPresenter(SearchContract.Presenter presenter) {
        this.presenter = presenter;
    }

    @OnClick(R.id.search_btn)
    public void onViewClicked() {
        presenter.subData();
    }
}
